<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>10_员工列表练习</title>
</head>
<body>
<form action="#">
    <input type="text" id="i1" placeholder="请输入员工姓名">
    <input type="text" id="i2" placeholder="请输入员工工资">
    <input type="text" id="i3" placeholder="请输入员工岗位">
    <button onclick="addform()">添加员工</button>
</form>
<hr>
<table border="1px">
    <caption>
        员工表
    </caption>
    <tr>
        <th>姓名</th>
        <th>工资</th>
        <th>岗位</th>
    </tr>
</table>
<script>

    let arr=[];

    function addform() {
        var uname = document.getElementById('i1').value;
        var salary = document.getElementById('i2').value;
        var job = document.getElementById('i3').value;

        var trE = document.createElement('tr');
        var td1E=document.createElement('td')
        var td2E=document.createElement('td')
        var td3E=document.createElement('td')

        td1E.innerHTML=uname;
        td2E.innerHTML=salary;
        td3E.innerHTML=job;
        trE.append(td1E,td2E,td3E);
        document.querySelector('table').append(trE);
        document.getElementById('i1').value='';
        document.getElementById('i2').value='';
        document.getElementById('i3').value='';

        arr.push({
            uName:uname,
            salary:salary,
            job:job
        })

        console.log(arr)

    }

</script>

</body>
</html>